package org.domain.sigepac.session;

import org.domain.sigepac.Utils;
import org.domain.sigepac.Entity.Parceiro;
import org.domain.sigepac.Entity.TipoParceiro;
import org.domain.sigepac.home.EntityHomeSupport;
import org.domain.sigepac.repository.RepositorioParceiro;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.FlushModeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.international.StatusMessages;

@Name("parceiroHome")
@Scope(ScopeType.CONVERSATION)
public class ParceiroHome extends EntityHomeSupport<Parceiro> {


	private static final long serialVersionUID = 7698596678249602179L;

	@In
	private StatusMessages statusMessages;

	@In
	private RepositorioParceiro repositorioParceiro;

	public ParceiroHome() {
		// TODO Auto-generated constructor stub
	}


	@Override
	protected Parceiro createInstance() {
		return new Parceiro();
	}



	public void salvar(){

		if(isManaged())
		{
			update();
			updatedMessage();
		}else{
			persist();
			createdMessage();
		}
		Utils.entityManagerFlush();

	}

	@Begin(flushMode=FlushModeType.MANUAL,join=true)
	public void setIdParceiro(Integer id) {
	    setId(id);

	 }

	public Integer getIdParceiro() {
	    return (Integer) getId();
	  }

	public TipoParceiro getTipoParceiroInterno(){
		return TipoParceiro.INTERNO;
	}

}
